<?php
import("Com.Auth");
class IndexAction extends Action
{
public function _initialize(){
		$this->assign('no',Auth::getno());
    	$this->assign('name',Auth::getname());
    	$this->assign('role',Auth::getrole());
	}
    /**
    +----------------------------------------------------------
    * 默认操作
    +----------------------------------------------------------
    */
    public function index()
    {
        $this->display();
    }

function MaterialRequire()//申请材料
    {
    	 if(Auth::getrole()!='教师')
    		exit('权限不够');
    	else{
	$condition['id']=$_POST['id'];
	$condition['num']=$_POST['num'];
	$condition['amount']=$_POST['amount'];
	$condition['labroom']=$_POST['labroom'];
	$condition['equ']=$_POST['equ'];
	$condition['labname']=$_POST['labname'];
	$condition['usetime']=$_POST['usetime'];
    $data=M("Buymaterial")->add($condition);
  //  echo M("Equipment")->getLastSql(); 
    
	if($data)
	{
		echo "提交成功！页面将在 3 秒后跳转到登陆界面！"; 
		echo("<meta http-equiv=refresh content=3;url=index>");}
	else
	{
		echo "提交失败！页面将在 3 秒后跳转到登陆界面！"; 
		echo("<meta http-equiv=refresh content=3;url=material>");
	}
	
    	}
    }
    
function ClassRequire()//申请班级
    {
    	 if(Auth::getrole()!='教师')
    		exit('权限不够');
    	else{
	$condition['id']=$_POST['id'];
	$condition['time']=$_POST['time'];
	$condition['peoplenum']=$_POST['peoplenum'];
    $data=M("Labclass")->add($condition);
  //  echo M("Equipment")->getLastSql(); 
    
	if($data)
	{
		echo "提交成功！页面将在 3 秒后跳转到登陆界面！"; 
		echo("<meta http-equiv=refresh content=3;url=index>");}
	else
	{
		echo "提交失败！页面将在 3 秒后跳转到登陆界面！"; 
		echo("<meta http-equiv=refresh content=3;url=class>");
	}
    	}
    }
    
    /**
    +----------------------------------------------------------
    * 探针模式
    +----------------------------------------------------------
    */
    public function checkEnv()
    {
        load('pointer',THINK_PATH.'/Tpl/Autoindex');//载入探针函数
        $env_table = check_env();//根据当前函数获取当前环境
        echo $env_table;
    }

}
?>